<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class PublicacionController extends Controller
{
    public function actionIndex()
    {
        // renders the view file 'protected/views/diseno/index.php'
        // using the default layout 'protected/views/layouts/main.php'
        $this->pageTitle = "SOSI - Interfaz de Publicacion de la Encuesta";
        $dataProvider = new CActiveDataProvider('Encuesta');
        $this->render('index',array(
                'dataProvider'=>$dataProvider,
        ));
    }
    
    public function actionView($id){
        $this->render('view',array(
                'model'=>$this->loadModel($id),
            ));
    }
    
    public function loadModel($id)
    {
        $model=Encuesta::model()->findByPk($id);
        if($model===null)
            throw new CHttpException(404,'The requested page does not exist.');
        return $model;
    }
    
    public function actionShare($id)
    {
        $shareEnc = Yii::app()->ePdf->mpdf();
        $shareEnc->WriteHTML($this->renderPartial('viewshare',array(
                'model'=>$this->loadModel($id),
                ),true)
            );
        $shareEnc->Output();
    }
}
?>
